<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发布微博</title>
</head>
<body>
<h1>发布微博</h1>
<form action="">
    <input type="text" name="title" placeholder="标题"><br>
    <input type="text" name="content" placeholder="正文"><br>
    <input type="file" name="picFile"><br>
    <input type="button" value="开始上传" @click="send()">
</form>

<!--引入axios和vue-->
<script src="js/axios.min.js"></script>
<script src="js/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{},
        methods:{
            send:function () {
                let data = new FormData(document.querySelector("form"));
                if (data.get("picFile").name == ""){
                    alert("请选择上传的图片文件")
                    return;
                }
                axios.post("/weibo/insert",data).then(function (response) {
                    if (response.data == 1){
                        alert("发布完成!")
                        location.href = "/";
                    }else {
                        alert("请登录!")
                        location.href = "/login.html";
                    }
                })
            }
        }
    })
</script>
</body>
</html>